package com.liujg.future.model.resp;

import com.liujg.future.constant.ShopConstants;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class BaseResult<T> implements Serializable {

    private T result;


    private String code;

    private String msg;

    public BaseResult(T data) {
        this.result = data;
        this.code = ShopConstants.SUCCESS_CODE;
        this.msg = ShopConstants.SUCCESS_MSG;
    }


    public static BaseResult<String> fail(String msg, String code) {
        return new BaseResult<String>("", code,msg );
    }

    public static BaseResult<String> fail(String msg) {
        return new BaseResult<String>("", ShopConstants.FAIL_CODE,msg );
    }
}
